part of 'widget.dart';

class _UserProgressBlockWloc extends StatefulWloc<_UserProgressBlockWlocState, UserProgressBlock> {
  late final bloc.UserProgressBlockBloc _bloc;

  @override
  _UserProgressBlockWlocState get initialState {
    return _UserProgressBlockWlocStateFactory().create(
      blocState: _bloc.state,
    );
  }

  void _onBlocStateChanged(bloc.UserProgressBlockBlocState blocState) {
    final updatedState = _UserProgressBlockWlocStateFactory().create(
      blocState: blocState,
    );

    emit(updatedState);
  }

  @override
  void initState() {
    super.initState();

    _bloc = bloc.UserProgressBlockBloc(
      learningContentBloc: core_di.sl(),
      getInitialData: user_progress_block_di.sl(),
      handleLearningContentOuterUpdate: user_progress_block_di.sl(),
    );

    _bloc.stream.listen(_onBlocStateChanged);
  }

  @override
  void dispose() {
    _bloc.close();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return _UserProgressBlockView(
      wloc: this,
    );
  }
}
